package lt.laimis.shop.web.action.product;

import lt.laimis.shop.web.action.node.NodeAcionBean;
import lt.laimis.shop.service.product.Product;
import lt.laimis.shop.service.product.ProductService;
import lt.laimis.shop.service.content.Content;
import lt.laimis.shop.service.content.ContentService;
import net.sourceforge.stripes.action.UrlBinding;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.integration.spring.SpringBean;

/**
 * Created by IntelliJ IDEA.
 * User: laimis
 * Date: Jul 19, 2008
 * Time: 4:00:27 PM
 * To change this template use File | Settings | File Templates.
 */

@UrlBinding("/product/view.do")
public class ViewActionBean extends NodeAcionBean {
    private String productId;
    private Product product;

    public Product getProduct() {
        if(this.product == null && productService != null && this.productId != null){
                this.product =  productService.getProductByNodeId(this.productId);
        }
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }


    @DefaultHandler
    public Resolution addition() {
        return new ForwardResolution("/product/view.jsp");
    }
}
